{template header}
<script src="static/bootstrap/js/utils.js"></script>
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>
<script type="text/javascript">
  window.onload=function ()
  {
      message = '{$message}';
      if(message != '')
      {
          alert(message);
      }
  }
  function checkUer(uid)
  {
    uid = $("#uid").val();
    if(Utils.isInt(uid) == false)
    {
      alert('请输入正确的用户ID');
      return false;
    }
    $.ajax({url:"index.php?c=admin&a=checkVipUser&uid=" + uid,
            async:false,
            dataType:"json",
            error:function(){
                alert('未知错误');
                },
            success:function(data, status){
                turnData = eval(data);
                if(turnData.message == '')
                {
                    $("#nickname").val(turnData.nickname)
                    $("#header").val(turnData.header);
                }
                else
                {
                  alert(turnData.message);
                  $("#nickname").val('')
                  $("#header").val('');
                }
            }
        });
    return false;
  }
  function checkSubmit(frm)
  {
    var uid = frm.uid.value;
    var nickname = frm.nickname.value;
    var comment_content = frm.content.value;

    var mess = '';
    if(Utils.isEmpty(uid)) {
      mess = mess + '用户ID不能为空\n';
    }
    
    if(Utils.isEmpty(comment_content)) {
      mess = mess + '评论内容不能为空\n';
    }
    if(!Utils.isEmpty(mess))
    {
      alert(mess);
      return false;
    }
    return true;
  }
</script>
<form enctype="multipart/form-data" class="form-horizontal" action="index.php?c=admin&a=addGearComment&type=insert" method="post" name="commentForm" onsubmit="return checkSubmit(this)">
  <div class="control-group">
    <label class="control-label" for="inputTiltle">用户ID：</label>
    <div class="controls">
      <select name="uid">
                <option value="">请选择</option>
                {loop $userlist $k $v}
                <option value="{$v['uid']}">$v['nickname']</option>
                {/loop}
           </select>
    </div>
  </div>
  <div class="control-group" style="display: none">
    <label class="control-label" for="inputShortDesc">用户昵称：</label>
    <div class="controls">
      <input type="text" id="nickname" name="nickname" placeholder="暂无法获取用户昵称" value="{$commentInfo['nickname']}" readonly="readonly">
    </div>
  </div>
  <div class="control-group" style="display:none">
    <label class="control-label" for="inputShortDesc">用户头像：</label>
    <div class="controls">
      <input type="text" id="header" name="header" placeholder="暂无法获取用户头像" value="{$commentInfo['header']}" readonly="readonly" style="width:50%;">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="inputShortDesc">评论内容：</label>
    <div class="controls">
      <textarea name="content" placeholder="请输入评论" style="min-width:80%; min-height:200x;">{$commentInfo['content']}</textarea>
    </div>
  </div>

  <div class="control-group">
    <label class="control-label" for="inputShortDesc">评论图：</label>
    <div class="controls">
      <input type="file" name="image" value="{$commentInfo['image']}">
    </div>
  </div>

<div class="control-group" style="display: none">
    <label class="control-label" for="inputScore">评分：</label>
    <div class="controls">
      <input type="text" name='score' placeholder="请输入评分" value="{$commentInfo['score']}">
      <span>0到5之间的整数</span>
    </div>
  </div>


  <div class="control-group">
    <label class="control-label" for="inputaddtime">设置添加时间：</label>
    <div class="controls">
      <input type="text" name="addTime" readonly="readonly" id="add_time_id" value="{eval echo date('Y-m-d H:i:s', $commentInfo['addTime'])}">
      <input name="add_time_btn" type="button" id="add_time_btn" onclick="return showCalendar('add_time_id', '%Y-%m-%d %H:%M:%S', '24', false, 'add_time_btn');" value="选择" class="button" id="add_time_id"/>
    </div>
  </div>
  <div class="control-group">
    <div class="controls">
        <input type="hidden" name="gearId" value="{$commentInfo['gearId']}">
        <button type="submit" class="btn">添加</button>
    </div>
  </div>
</form>
{template footer}